package com.cungmua.app.model;

import com.cungmua.app.utils.AppConfig;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.io.Serializable;
import java.text.ParseException;
import java.util.Date;

/**
 * Created by kelvin.nguyen on 6/16/14.
 */
@JsonIgnoreProperties(ignoreUnknown = true)
public class User implements Serializable {
    private int id;
    private String email;
    private String name;
    private Date dateOfBirth;
    private String mobile;
    private int gender;
    private Date createdAt;
    private String fullTextAddress;
    private String token;

    public User() {
    }

    public static User defaultUser() {
        User r = new User();
        r.setId(0);
        r.setToken(AppConfig.getDefaultToken());

        return r;
    }

    @JsonProperty("Id")
    public void setId(int id) {
        this.id = id;
    }

    @JsonProperty("Email")
    public void setEmail(String email) {
        this.email = email;
    }

    @JsonProperty("Name")
    public void setName(String name) {
        this.name = name;
    }

    @JsonProperty("Birthday")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MM/dd/yyyy", timezone = "ICT")
    public void setDateOfBirth(Date dateOfBirth) {
        this.dateOfBirth = dateOfBirth;
    }

    @JsonProperty("Mobile")
    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    @JsonProperty("Gender")
    public void setGender(int gender) {
        this.gender = gender;
    }

    @JsonProperty("CreationDate")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MM/dd/yyyy", timezone = "ICT")
    public void setCreatedAt(Date createdAt) throws ParseException {
        this.createdAt = createdAt;
    }

    @JsonProperty("AddressFullText")
    public void setFullTextAddress(String fullTextAddress) {
        this.fullTextAddress = fullTextAddress;
    }

    @JsonProperty("Token")
    public void setToken(String token) {
        this.token = token;
    }

    public int getId() {
        return id;
    }

    public String getEmail() {
        return email;
    }

    public String getName() {
        return name;
    }

    public String getMobile() {
        return mobile;
    }

    public int getGender() {
        return gender;
    }

    public Date getDateOfBirth() {
        return dateOfBirth;
    }

    public Date getCreatedAt() {
        return createdAt;
    }

    public String getFullTextAddress() {
        return fullTextAddress;
    }

    public String getToken() {
        return token;
    }
}